package com.iot.system.service.impl;

import java.util.List;
import com.iot.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.iot.system.mapper.LineHourYieldsInfoMapper;
import com.iot.system.domain.LineHourYieldsInfo;
import com.iot.system.service.ILineHourYieldsInfoService;

/**
 * 产线小时产量Service业务层处理
 * 
 * @author iot
 * @date 2025-02-24
 */
@Service
public class LineHourYieldsInfoServiceImpl implements ILineHourYieldsInfoService 
{
    @Autowired
    private LineHourYieldsInfoMapper lineHourYieldsInfoMapper;

    /**
     * 查询产线小时产量
     * 
     * @param id 产线小时产量主键
     * @return 产线小时产量
     */
    @Override
    public LineHourYieldsInfo selectLineHourYieldsInfoById(Long id)
    {
        return lineHourYieldsInfoMapper.selectLineHourYieldsInfoById(id);
    }

    /**
     * 查询产线小时产量列表
     * 
     * @param lineHourYieldsInfo 产线小时产量
     * @return 产线小时产量
     */
    @Override
    public List<LineHourYieldsInfo> selectLineHourYieldsInfoList(LineHourYieldsInfo lineHourYieldsInfo)
    {
        return lineHourYieldsInfoMapper.selectLineHourYieldsInfoList(lineHourYieldsInfo);
    }

    /**
     * 新增产线小时产量
     * 
     * @param lineHourYieldsInfo 产线小时产量
     * @return 结果
     */
    @Override
    public int insertLineHourYieldsInfo(LineHourYieldsInfo lineHourYieldsInfo)
    {
        lineHourYieldsInfo.setCreateTime(DateUtils.getNowDate());
        return lineHourYieldsInfoMapper.insertLineHourYieldsInfo(lineHourYieldsInfo);
    }

    /**
     * 修改产线小时产量
     * 
     * @param lineHourYieldsInfo 产线小时产量
     * @return 结果
     */
    @Override
    public int updateLineHourYieldsInfo(LineHourYieldsInfo lineHourYieldsInfo)
    {
        return lineHourYieldsInfoMapper.updateLineHourYieldsInfo(lineHourYieldsInfo);
    }

    /**
     * 批量删除产线小时产量
     * 
     * @param ids 需要删除的产线小时产量主键
     * @return 结果
     */
    @Override
    public int deleteLineHourYieldsInfoByIds(Long[] ids)
    {
        return lineHourYieldsInfoMapper.deleteLineHourYieldsInfoByIds(ids);
    }

    /**
     * 删除产线小时产量信息
     * 
     * @param id 产线小时产量主键
     * @return 结果
     */
    @Override
    public int deleteLineHourYieldsInfoById(Long id)
    {
        return lineHourYieldsInfoMapper.deleteLineHourYieldsInfoById(id);
    }

    @Override
    public Boolean judgmentLineHourEnergy(LineHourYieldsInfo lineHourYieldsInfo) {
        if (lineHourYieldsInfo.getLineId() != null && lineHourYieldsInfo.getLineStartTime() != null) {
            int i = lineHourYieldsInfoMapper.judgmentLineHourEnergy(lineHourYieldsInfo);
            if (i>0){
                return false;
            }
        }
        return true;
    }
}
